package com.balabala.gym_system.controller.app;

import com.balabala.goods.api.CourseFeignClient;
import com.balabala.goods.api.GoodsFeignClient;

import com.balabala.goods.pojo.Spu;
import com.balabala.goods.pojo.vo.CourseDto;
import com.balabala.gym_system.dao.AdvertisingDao;
import com.balabala.gym_system.pojo.dto.AdvertisingDto;
import com.balabala.gym_system.pojo.entity.Advertising;
import com.balabala.gym_system.pojo.entity.Notice;
import com.balabala.gym_system.service.NoticeService;
import com.balabala.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Author:zl
 * Date:2023/5/6 14:10
 */
@RequestMapping("/app/admin")
@RestController
@CrossOrigin
@Api(tags = "小程序首页管理接口")
public class HomeController {

    @Autowired
    private AdvertisingDao advertisingDao;
    @Autowired
    private NoticeService noticeService;
    @Autowired
    private GoodsFeignClient goodsFeignClient;
    @Autowired
    private CourseFeignClient courseFeignClient;

    @ApiOperation(value = "查询所有广告")
    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    public Result findAll(AdvertisingDto advertisingDto) {
        List<Advertising> adByAdvertisingDto = advertisingDao.findAdByAdvertisingDto(advertisingDto);
        return Result.ok(adByAdvertisingDto);
    }

    @ApiOperation(value = "推荐私教")
    @RequestMapping(value = "/findCoachClass", method = RequestMethod.GET)
    public Result findCoachClass() {
        //远程调用根据课程推荐指数查询出私教课信息

        return Result.ok();
    }

    @ApiOperation(value = "推荐课程")
    @RequestMapping(value = "/findClass", method = RequestMethod.GET)
    public Result findClass() {
        //远程调用根据课程推荐指数查询
        Result<List<CourseDto>> all = courseFeignClient.findAll();
        return Result.ok(all.getData());
    }

    @ApiOperation(value = "周边商品")
    @RequestMapping(value = "/findPeripherals", method = RequestMethod.GET)
    public Result findPeripherals() {
        //调用商品的所有查询
        Result<List<Spu>> all = goodsFeignClient.findAll();
        return Result.ok(all);
    }

    @ApiOperation(value = "公告通知")
    @RequestMapping(value = "/findNotice", method = RequestMethod.GET)
    public Result findNotice() {
        //查询通知
        List<Notice> list = noticeService.list();
        return Result.ok(list);
    }


}
